import os

from logger.tensorboard_logger import TensorboardLogger
from logger.sample_logger import SampleLogger
from logger.scalar_logger import XlsxLogger

class ComprehensiveLogger:

    def __init__(self, **kwargs):
        
        self.tb_logger = TensorboardLogger(**kwargs)
        self.c_logger = SampleLogger(**kwargs)

        if not "xlogger_dir" in kwargs and not self.c_logger.save_dir is None:
            kwargs["xlogger_dir"] = os.path.join(
                self.c_logger.save_dir, "_xlsx"
            )

        self.x_logger = XlsxLogger(**kwargs)
        
        self.loggers = [self.tb_logger, self.c_logger]


    def __getattr__(self, method_name):

        log_fn = None

        for obj in self.loggers:
            log_fn = getattr(obj, method_name, None)

            if not log_fn is None:
                break

        if log_fn:
            return log_fn
        else:
            raise AttributeError(method_name)

